
//判断obj在数组中的位置         代替indexOf
export function ArrIndexOf(arr, obj, key = 'rid'){
    for(let i = 0;i < arr.length;i++){
        if(arr[i] == obj){
            return i;
        }else if(JSON.stringify(arr[i]) === JSON.stringify(obj)){
            return i;
        }else if(obj[key] && arr[i][key] == obj[key]){
            return i;
        }
    }
    return -1;
}


//时间转化
export function timifrom(currentTime){
    var m = Math.floor(currentTime/60) < 10 ? "0" + Math.floor(currentTime/60) : Math.floor(currentTime/60)
    var s = Math.floor(currentTime-(m * 60)) < 10 ? "0" + Math.floor(currentTime-(m * 60)) : Math.floor(currentTime-(m * 60))
    return m + ":" + s;
}


export function htmlFrom(html){
    let z = /\n/g
    let k = /\s/g
    return html.replace(z, '<br>').replace(k, '&nbsp;')
}

export default {
	ArrIndexOf,
    timifrom,
    
}